how to find number of factors in java